<script type="text/javascript">
<!--
<?php if (!$embedded): ?>
$(document).ready(function(){
  $.vtnsFilters.setSettings({debug: false, defaultCategoryId: <?php echo Category::DEFAULT_CATEGORY ?>, defaultSubCategoryId: <?php echo Category::DEFAULT_SUBCATEGORY ?>});
  $.vtnsFilters(<?php echo json_encode($filters->getRawValue()) ?>);
});
<?php endif ?>
var search_has_text = {filter_keyword: false};
<?php if (!isset($filters['location'])): ?>
  search_has_text.filter_location = false;
<?php endif ?>
var search_default_text = {filter_keyword: "<?php echo __('Keywords') ?>", filter_location: "<?php echo __('Location') ?>"};
function searchFocus(control)
{
    control = $(control);
    var name = control.attr('name');
    if (!search_has_text[name]) {
        search_has_text[name] = true;
        control.val('');
    }
}

function searchBlur(control)
{
    control = $(control);
    var name = control.attr('name');
    if (control.val() == '') {
        control.val(search_default_text[name]);
        control.removeClass('selected');
        search_has_text[name] = false;
    } else {
        control.addClass('selected');
        search_has_text[name] = true;
    }
}

-->
</script>
<div id="search_filters" class="vtns_search<?php echo $displayLocationSearchField ? '' : '_glued'; ?>">
  <div class="search">
    <?php // Full text search field ?>
    <div class="fleft">
      <input type="text" id="filter_keyword" class="inputtext_search fleft DOMControl_placeholder" onfocus="searchFocus(this)" onblur="searchBlur(this)" name="filter_keyword" value="<?php echo $keyword_filter_value ?>" />
    <?php if ($displayLocationSearchField): ?>
    </div>

    <div class="fleft">
      <input type="text" id="filter_location" class="inputtext_search fleft DOMControl_placeholder" onfocus="searchFocus(this)" onblur="searchBlur(this)"  name="filter_location" value="<?php echo $location_filter_value ?>" />
    <?php endif ?>
      <input id="qsearch_submit" type="submit" value="<?php echo __("OK") ?>" class="vtns_buttonBlue button_search fleft" />
    </div>
  </div><!-- .search -->

  <?php if ($embedded):
    include_partial('filters/select_filters', array(
            'sf_request'          => $sf_request,
            'filters'             => $filters,
            'addCountryFilter'    => $addCountryFilter,
            'countries'           => $countries,
            ))
  ?>
  <?php else: ?>
  <div id="filter">
    <!-- Select filters -->
    <?php $filter_count = count($filters); $count = 0;
    foreach ($filters as $filter_name => $filter):
      if ($filter_name === 'category') continue ?>
        <div id="filter_<?php echo $filter_name ?>_wrapper">
          <?php
          $count++;
          include_partial('filters/job_filters', array(
                  'count' => $count,
                  'filter_name' => $filter_name,
                  'filter' => $filter,
                  'last' => (--$filter_count == 0),
                  )) ?>
        </div>
    <?php endforeach ?>
  </div>
  <?php endif ?>
</div>
